Skip to content

feat(operator): static membership#346

Open
bmcquilkin-sentry wants to merge 1 commit into
bmcquilkin/operator/podsfrom
bmcquilkin/operator/membership
Open

feat(operator): static membership#346
bmcquilkin-sentry wants to merge 1 commit into
bmcquilkin/operator/podsfrom
bmcquilkin/operator/membership

Conversation

@bmcquilkin-sentry

@bmcquilkin-sentry bmcquilkin-sentry commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds static membership to consumers (and also adds some type fix mypy was complaining about).

@bmcquilkin-sentry
bmcquilkin-sentry requested a review from a team as a code owner July 22, 2026 00:01

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cfec667. Configure here.

)
def test_build_kafka_consumer_config(
source_config: StepConfig,
source_config: KafkaConsumerConfig,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests ignore static membership env

Low Severity

test_build_kafka_consumer_config asserts exact override_params but never clears STREAMS_KAFKA_GROUP_INSTANCE_ID. After this change, build_kafka_consumer_config injects group.instance.id from that env var, so these cases fail whenever it is set. The newer static-membership tests already use monkeypatch.delenv, so this looks like a missed update.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cfec667. Configure here.

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

STREAM-1644

@fpacifici fpacifici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pelase address my comments on the usage of hte environment variable.

override_params = consumer_config.get("override_params", {})
override_params = dict(consumer_config.get("override_params", {}))

group_instance_id = os.environ.get("STREAMS_KAFKA_GROUP_INSTANCE_ID")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to read environment variables from inside the adapter. The code that reads the config file is already able to transparently swap a config field with an environment variable provided according to a standard format
https://github.com/getsentry/streams/blob/main/sentry_streams/sentry_streams/pipeline/config.py#L26-L32

See an example of how this is used

This means you can leverage the standard override mechanism without doing anything special for group.instance.id here.

More in general, beware of reading random environment variables deep in the stack. That makes it very hard to track down how to configure your system.
A better option is to have a config abstraction that provide the whole configuration and takes care to resolve, config files, overrides with environment variables and other ways to configure the system.
Then you separate the concerns cleanly. One system manages the loading of the config and another consumes it. The system consuming the config does not have to care where the value comes from.

[
pytest.param(
{
"starts_segment": None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this ? start_segment is not an attribute of KafkaConsumerConfig

def test_build_kafka_consumer_config_injects_static_membership(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("STREAMS_KAFKA_GROUP_INSTANCE_ID", "consumer-2")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to monkeypatch environment variables. Just set that with os.environ["blabla"] = "blabla".

In general please try to avoid monkey patching whenever it is not strictly necessary. It is really hard to makes sense of the behavior of the class you are patching when it evolves.

@fpacifici
fpacifici self-requested a review July 23, 2026 23:46

@fpacifici fpacifici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicked the wrong button, please see my comments above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants